<?php
include("../functions.php");
include("../libs/smarty.class.php");

$smarty = new Smarty();

$title = "Praktyki";
$smarty->assign("title",$title);

$accept_id = $_GET['accept_id'];
if($accept_id != ''){
    echo acceptPractice($accept_id);
    $info_action = getInfo(15);
    $info_color = "green";
}
$delete_id = $_GET['delete_id'];
if($delete_id !=''){
    echo deletePractice($delete_id);
    $info_action = getInfo(16);
    $info_color = "red";
}


$sql = mysql_query("SELECT p.id,p.add_date,p.date_start,p.date_end,p.amount,p.status,
    (SELECT co.name FROM user_company co WHERE (p.company_id = co.id)) AS company_name
    FROM practices p WHERE p.status = 1 LIMIT 0, 30 ");

$practices = array();

while($row = mysql_fetch_assoc($sql)){
    $practices[] = $row;

}
$smarty->assign("practices",$practices);

$sql2 = mysql_query("SELECT p.id,p.add_date,p.date_start,p.date_end,p.amount,p.status,
    (SELECT co.name FROM user_company co WHERE (p.company_id = co.id)) AS company_name
    FROM practices p WHERE p.status = 0 LIMIT 0, 30 ");

$practicesToAccept = array();

while($row = mysql_fetch_assoc($sql2)){
    $practicesToAccept[] = $row;

}
$smarty->assign("practicesToAccept",$practicesToAccept);

$smarty->assign("info_action",$info_action);
$smarty->assign("info_color",$info_color);
$smarty->display('practices.tpl');
?>
